package AccountWindow.HotelAdmin;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class HotelAdminWindowHandler implements ActionListener {
    private HotelAdminWindow hotelAdminWindow;

    public HotelAdminWindowHandler(HotelAdminWindow hotelAdminWindow) {
        this.hotelAdminWindow = hotelAdminWindow;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        String actionCommand = e.getActionCommand();
        System.out.println("actiondCommand=" + actionCommand);

        try {
            if ("roomDetail".equals(actionCommand)) {
                hotelAdminWindow.cardLayout.show(hotelAdminWindow.hotelAdminPanel, "roomDetailPanel");
            } else if ("accountDetail".equals(actionCommand)) {
                hotelAdminWindow.cardLayout.show(hotelAdminWindow.hotelAdminPanel, "accountDetailPanel");
                hotelAdminWindow.accountDetailWindow.refreshAccountDetailPanel();
            } else if ("personalDetail".equals(actionCommand)) {
                hotelAdminWindow.cardLayout.show(hotelAdminWindow.hotelAdminPanel, "personalDetailPanel");
            }
        } catch (Exception error) {
            error.printStackTrace();
        }
    }
}